package me.hys.api.user;

import me.hys.api.BaseApi;
import me.hys.base.ApiResult;
import me.hys.entity.system.DeviceTokenEntity;
import me.hys.service.system.IDeviceTokenManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: @author HYS . <br>
 * Date: 2015-10-20 下午9:58:18 . <br>
 * Function:
 */
@Controller
@RequestMapping("/api/device")
public class DeviceApi extends BaseApi {

	@Autowired
	private IDeviceTokenManager deviceTokenManager;

	/**
	 * @Title : get
	 * @Description : 获取
	 */
	@ResponseBody
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	public DeviceTokenEntity get(@RequestParam String deviceToken) {
		return deviceTokenManager.findByDeviceToken(deviceToken);
	}

	/**
	 * @Title : post
	 * @Description : 上传device token
	 */
	@ResponseBody
	@RequestMapping(value = "/post", method = RequestMethod.POST)
	public ApiResult post(@ModelAttribute DeviceTokenEntity entity) {
		return deviceTokenManager.save(entity);
	}

}
